package com.zimmur.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.zimmur.controller.BaseController;

/**
 * 基础拦截器
 * @author Administrator
 *
 */
public class BaseInterceptor extends HandlerInterceptorAdapter {

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		BaseController.setRequest(request);
		BaseController.setResponse(response);
		
		return true;
	}

	@Override
	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
			throws Exception {
		BaseController.removeRequest();
		BaseController.removeResponse();
		//super.afterCompletion(request, response, handler, ex);
	}
}
